package com.foss.push.utils;

import android.content.Context;
import android.util.Log;

import com.foss.push.config.DeviceInfoUtil;
import com.foss.push.config.Preferences;
import com.foss.push.config.PushConstants;
import com.foss.push.config.PushPreferences;
import com.foss.push.nodeclient.DeviceCheckinVo;
import com.foss.push.nodeclient.TagEntryVo;
import com.foss.push.zillasdk.Zilla;
import com.foss.push.zillasdk.ZillaDelegate;
import com.google.gson.Gson;

//import com.foreveross.bsl.util.Preferences;
//import com.foss.DeviceInfoUtil;
//import com.foreveross.chameleonsdk.config.URL;

public class CheckInUtil {
	public final static String TAG = "CheckInUtil";
	public static void registerPush(final Context application,String token,ZillaDelegate delegate){
            final DeviceCheckinVo checkinVo = new DeviceCheckinVo();
            checkinVo.setDeviceId(DeviceInfoUtil.getDeviceId());
            checkinVo.setAppId(PushConstants.APPKEY);
        Log.d(TAG,"AppKey == " + PushConstants.APPKEY);
            checkinVo.setChannelId("instant");
            checkinVo.setDeviceName(android.os.Build.MODEL);
            checkinVo.setOsName("android");
            checkinVo.setOsVersion(android.os.Build.VERSION.RELEASE);
            checkinVo.setPushToken(token);
            checkinVo.setTags(new TagEntryVo[]{new TagEntryVo("platform", "Android")});
            Zilla.getZilla().pushCheckIn(application,delegate, new Gson().toJson(checkinVo));

    }
	
	public static void pushSecurity(final Context application , final String role){
        PushPreferences preferences=new PushPreferences(application);
        String token= preferences.getToken();
        final DeviceCheckinVo checkinVo = new DeviceCheckinVo();
		checkinVo.setDeviceId(DeviceInfoUtil.getDeviceId());
		checkinVo.setAppId(PushConstants.APPKEY);
		String alias = Preferences.getUserName();
		checkinVo.setAlias(alias);
		checkinVo.setChannelId("instant");
		checkinVo.setDeviceName(android.os.Build.MODEL);
		checkinVo.setOsName("android");
		checkinVo.setOsVersion(android.os.Build.VERSION.RELEASE);
		checkinVo.setPushToken(token);
		checkinVo.setTags(new TagEntryVo[] { 
				new TagEntryVo("platform", "Android") ,
				new TagEntryVo("role", role) });
		
		
		ZillaDelegate delegate = new ZillaDelegate() {
			
			@Override
			public void requestSuccess(String result) {
				
			}
			
			@Override
			public void requestStart() {
				
			}
			
			@Override
			public void requestFailed(String errorMessage) {
				
			}
		};
		
		Zilla.getZilla().pushCheckIn(application, delegate, new Gson().toJson(checkinVo));
	}

}
